<?php

//////////////////////////////////////////////////////
// GPAC Database is Copyright 2002 Colin Todd       //
// Written by Colin Todd - All rights reserved.     //
//                                                  //
// colintodd@myfastmail.com                         //
//////////////////////////////////////////////////////

$bDebug = FALSE;
//$bDebug = TRUE;

//check user is logged in
include_once('_includes/master_include.php');

$root = './';
include($root . 'include/header.php');
include($root . 'include/dbconnect.php');
///$alphabet = @$_GET['alphabet'];
///$result = mysql_query("SELECT * FROM $individual WHERE Surname LIKE '$alphabet%' ORDER BY Surname",$PACTS_cfg->dblink);
$PHPSESSID = @$_GET['PHPSESSID'];
$CheckLevel = @$_GET['CheckLevel'];
$startFamilyId = @$_GET['startFamilyId'];

$MaxFixes = 100000; // default is all
$MaxFixes = @$_GET['MaxFixes'];

start_div_main();
?>

<table cellpadding="2" border="0">
<tr>
	<td>
<?php
	echo"<font class=\"titlename2\">Consistency Check</font>";
?>
	</td>
</tr></table>



<?php
//echo "<a href=\"".$_SERVER['PHP_SELF']."?CheckLevel=All\">Check All</a><br />";
echo "<font class=\"errmsg1\">Check Family</font> - ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=10\">10</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=20\">20</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=50\">50</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=100\">100</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=130\">130</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=180\">180</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=100000\">All</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Family&MaxFixes=DO\">Directory Only</a>";
	echo "<br />";
	echo "<h1>Checks Families for :-</h1>";
	echo "<UL>";
	echo "<LI>Residential Address Consistency\n";
	echo "<LI>Postal Address Consistency\n";
	echo "<LI>Home Telephone Number Consistency\n";
	echo "<LI>Home Fax Number Consistency\n";
	echo "<LI>\n";

	echo "<LI>Residential Address to use Postal where there isn't a res addr <b>(not yet implemented)</b>\n";
	echo "<LI>Duplicates <b>(not yet implemented)</b>\n";
	echo "<LI>Families containing Individuals with different or no surnames <b>(not yet implemented)</b>\n";
	echo "<LI>Familes with no 'Head Of Family' <b>(not yet implemented)</b>\n";

	echo "</UL>";

echo "<font class=\"errmsg1\">Check Individual</font> - ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=5\">5</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=10\">10</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=20\">20</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=50\">50</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=100\">100</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=200\">200</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=100000\">All</a> | ";
echo "<a class=\"smalltxt\" href=\"".$_SERVER['PHP_SELF']."?CheckLevel=Individual&MaxFixes=DO\">Directory Only</a>";

	echo "<h1>Checks Individuals for :-</h1>";
	echo "<UL>";
	echo "<LI>Work Telephone Phone Number Consistency\n";
	echo "<LI>Work Fax Phone Number Consistency\n";
	echo "<LI>Home Email Consistency\n";
	echo "<LI>Work Email Consistency\n";
	echo "<LI>'AgeRange' to Birthdate Consistency\n";
	echo "<LI>Duplicate (ie Firstname and Surname)\n";
	echo "<LI>'Orphan Individuals (ie not assigned to a Family)</b>\n";


	echo "</UL>";

//exit;
//

if($CheckLevel=="Family") {
// 'DO' is Directory Only
	if ($MaxFixes=="DO"){
		$MaxFixes= 100000;
		$sql_txt = "SELECT * FROM $family WHERE FamilyId In (SELECT FamilyId FROM `individual` WHERE  `ChurchDirectoryIndicator` = 'Y') ORDER BY FamilyShortName ";
	}else{
		$sql_txt = "SELECT * FROM $family  ORDER BY FamilyShortName ";
	}
/*
	echo "<h1>Checking Families for :-</h1>";
	echo "<UL>";
	echo "<LI>Residential Address Consistency\n";
	echo "<LI>Postal Address Consistency\n";
	echo "<LI>Home Telephone Number Consistency\n";
	echo "<LI>Home Fax Number Consistency\n";
	echo "</UL>";
*/
}

if($CheckLevel=="Individual") {
	if ($MaxFixes=="DO"){
		$MaxFixes=  100000;
		$sql_txt = "SELECT * FROM $individual WHERE `ChurchDirectoryIndicator` = 'Y' ORDER BY Surname ";
	}else{
		$sql_txt = "SELECT * FROM $individual ORDER BY Surname ";
	}
/*
	echo "<h1>Checking Individuals for :-</h1>";
	echo "<UL>";
	echo "<LI>Work Telephone Phone Number Consistency\n";
	echo "<LI>Work Fax Phone Number Consistency\n";
	echo "<LI>Home Email Consistency\n";
	echo "<LI>Work Email Consistency\n";
	echo "<LI>'AgeRange' to Birthdate Consistency\n";
	echo "</UL>";
*/
}

$countFixes = 1;

$HtmlText = "";

if(strlen($CheckLevel)>0) {

//		$sql_txt = "SELECT * FROM $individual WHERE IndividualId = 300";
	
	$result = mysql_query($sql_txt,$PACTS_cfg->dblink);
	$result_rowCount = mysql_num_rows($result);
	if ($bDebug) { print "<p>$sql_txt<p>"; }

	if ($MaxFixes > $result_rowCount ) {
		$MaxFixes=$result_rowCount ;
	}

	echo "<p>Checking ".$MaxFixes." out of ".$result_rowCount." rows...<p>";


// Fix Mobile Phone issue
	$sql_fix = "Update Individual set MobilePhoneNumber = Concat('0',MobilePhoneNumber) WHERE MobilePhoneNumber IS  NOT  NULL  AND Left( MobilePhoneNumber, 1  )  =  '4';
";
	$fix = mysql_query($sql_fix,$PACTS_cfg->dblink);

// Fix Std Phone number issue
	$sql_fix = "UPDATE Individual Set WorkPhoneStdCode = Concat('0',WorkPhoneStdCode) WHERE length( WorkPhoneStdCode ) = 1;";
	$fix = mysql_query($sql_fix,$PACTS_cfg->dblink);
	$sql_fix = "UPDATE Individual Set WorkFaxStdCode  = Concat('0',WorkFaxStdCode) WHERE length(WorkFaxStdCode) = 1;";
	$fix = mysql_query($sql_fix,$PACTS_cfg->dblink);

	$sql_fix = "UPDATE Family Set HomePhoneStdCode = Concat('0',HomePhoneStdCode) WHERE length(HomePhoneStdCode) = 1;";
	$fix = mysql_query($sql_fix,$PACTS_cfg->dblink);
	$sql_fix = "UPDATE Family Set HomeFaxStdCode = Concat('0',HomeFaxStdCode) WHERE length(HomeFaxStdCode) = 1;";
	$fix = mysql_query($sql_fix,$PACTS_cfg->dblink);


	while($row=mysql_fetch_assoc($result) and $countFixes<=$MaxFixes) {
		$errCompile = "";

/////////////////////////////////////////////////////////////////////////////////////////////////
// FAMILY
/////////////////////////////////////////////////////////////////////////////////////////////////
		if($CheckLevel=="Family") {

				$FamilyId = $row['FamilyId'];
				$familyShortName = getFormattedFamilyShortName($FamilyId,$dblink," ");

			if ($bDebug) { print "<h1>$FamilyId $familyShortName (Fixcount = $countFixes)</h1>\n ";}
			if ($bDebug) { print "$FamilyId  ".$row['ResidentialStateCode']." ".$row['ResidentialPostcode']." ".$row['ResidentialSuburb']."<p>";}
			$errCompile = "";
			$err = "";
			$errR = "";
			$errP = "";
			$err1 = "";

			$errR = checkAddressConsistency($FamilyId, "Family", "Residential",$row['ResidentialStateCode'], $row['ResidentialSuburb'], $row['ResidentialPostcode'], "<LI>" );

				if(strlen(trim($row['PostalAddressStateCode'].$row['PostalAddressSuburb'].$row['PostalAddressPostcode']))>0) {
					$errP = checkAddressConsistency($FamilyId, "Family", "PostalAddress", $row['PostalAddressStateCode'], $row['PostalAddressSuburb'], $row['PostalAddressPostcode'], "<LI>" );
				}
					if(strlen(trim($errR))>0 and strlen(trim($errP))>0) {
					$errCompile =  $errR."<LI>".$errP;
				} else {
					$errCompile =  trim($errR).trim($errP);
				}

				$err =  checkPhoneNumberConsistency($FamilyId, "Family", "HomePhone", $row['HomePhoneInternationalCode'], $row['HomePhoneStdCode'], $row['HomePhoneNumber'], "", "<LI>" );

				if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
					$errCompile .=  "<LI>".$err;
				}else{
 					$errCompile .=  trim($err);
				}

				$err =  checkPhoneNumberConsistency( $FamilyId, "Family", "HomeFax", $row['HomeFaxInternationalCode'], $row['HomeFaxStdCode'], $row['HomeFaxNumber'], "", "<LI>" );

				if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
					$errCompile .=  "<LI>".$err;
				}else{
					$errCompile .=  trim($err);
				}


				$err = checkAddressStreetNameNumberConsistency($FamilyId, "Family", "Residential", $row['ResidentialStreetNum'], $row['ResidentialStreetName'], "<LI>" );

				if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
					$errCompile .=  "<LI>".$err;
				}else{
					$errCompile .=  trim($err);
				}



			//Check that there are individuals in this family
			$sql_checkOrphanFamily = "Select count(*) from Individual where FamilyId = $FamilyId;";

			$result_Fmly_Indvcnt = LogQuery($sql_checkOrphanFamily,__LINE__,__FILE__ );
			$row_Fmly_Indvcnt = mysql_fetch_array($result_Fmly_Indvcnt);

			
			if ($row_Fmly_Indvcnt[0] == 0) {
				if (!$bDebug) { print "Orphan Found - $FamilyId $familyShortName <br />";}

				$errCompile.="<b>Orphan family found</b>. No individuals are in this family.";
				$errCompile.=": <a class=\"edit\" href=\"Fmly_edit.php?FamilyId=$FamilyId\" rel=\"external\"><font  ALT=\"MANUALLY EDIT THIS RECORD\">EDIT</font></a>";

				$fixLink="";
				$PHPSESSID = @$_GET['PHPSESSID'];

				$fixSQL = htmlentities(urlencode('DELETE FROM Family WHERE FamilyId = '.$FamilyId.';'));

				$fixLink="\n</UL>\n<table border=1 cellpadding=0 cellspacing=0>\n<tr>\n<td>\n<table>";
				$fixLink.="\n<tr><td>\n";
				$fixLink.="<b><center><font class=\"UpdateLinkTitle\">CLICK LINK TO DELETE RECORD</font></center></b>";
				$fixLink.="\n</td></td>\n";
				$fixLink .= "<tr><td>\n";
				$fixLink .= '<a href="javascript:openUpdateSql(\''.$fixSQL.'\', \''.$PHPSESSID.'\')" class="UpdateLink">';
				$fixLink .= "Delete $familyShortName Family record.</a>\n";
				$fixLink .= "\n";
				$fixLink .= "</td></tr>\n</table>\n</td></tr></table>\n";

				$errCompile.=$fixLink;

				$fixLink ="";
				$fixSQL ="";



			}
			

		


			// now print
				if(strlen(trim($errCompile))>0) {
					$HtmlText .= "\n<tr><td>\n";
					$familyShortName = getFormattedFamilyShortName($FamilyId,$dblink," ");
					$HtmlText .= "\n<a href=\"Fmly_view.php?FamilyId=".$FamilyId."\" rel=\"external\" title=\"View $familyShortName Family\"> ".$familyShortName." Family</a>\n";
					$HtmlText .= "</td>\n\n<td><UL>\n";		
					$HtmlText .= "<LI>$errCompile</UL>\n";
					$HtmlText .= "</td></tr>\n";		
					$countFixes++;
				}
		
			






		} // end if

/////////////////////////////////////////////////////////////////////////////////////////////////
// INDIVIDUAL
/////////////////////////////////////////////////////////////////////////////////////////////////


		if($CheckLevel=="Individual") {
			$IndividualId = $row['IndividualId'];

			if ($bDebug) { print "Checking : $IndividualId : ".$row['FirstName']." ".$row['Surname']." (countFixes = $countFixes)<p>";}
			// check Work Phone Number
			$err =  checkPhoneNumberConsistency($IndividualId, "Individual", "WorkPhone", $row['WorkPhoneInternationalCode'], $row['WorkPhoneStdCode'], $row['WorkPhoneNumber'], "", "<LI>" );
			
			if ($bDebug and strlen(trim($err))>0){print "Work Hpone Error code : $err <p>";}

			if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
				
				$errCompile .=  "<LI>".$err;
			}else{
				$errCompile .=  trim($err);
			}

////////////////////////////////////////////////////
			// check Work Fax Number
////////////////////////////////////////////////////

			if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
				$err = checkPhoneNumberConsistency($IndividualId, "Individual", "WorkFax", $row['WorkFaxInternationalCode'], $row['WorkFaxStdCode'], $row['WorkFaxNumber'], "" , "<LI>" );

				if ($bDebug) { print "checkPhoneNumberConsistency($IndividualId, Individual, WorkFax, ".$row['WorkFaxInternationalCode'].", ".$row['WorkFaxStdCode'].", ".$row['WorkFaxNumber'].", , LI );<p>";}

				$errCompile .=  "<LI>".$err;
			}else{
				$errCompile .=  trim($err);
			}

			// check Mobile Phone Number

//		Function checkPhoneNumberConsistency( $RecordId, $RecordType, $RecordPrefix, $CountryCode= "", $STD = "", $NonMobPhnumber = "", $MobPhnumber = "", $strDelim = "<LI>" 
	
			$err =  checkPhoneNumberConsistency($IndividualId, "Individual", "Mobile", $row['MobilePhoneInternationalCode'], "", "", $row['MobilePhoneNumber'], "<LI>" );
			if ($bDebug) {print "checkPhoneNumberConsistency($IndividualId, Individual, WorkFax, ".$row['MobilePhoneInternationalCode'].", ".$row['MobilePhoneNumber'].", LI );<p>";}
			if ($bDebug and strlen(trim($err))>0){print "Mobile Phone Error code : $err <p>";}

			if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
				$errCompile .=  "<LI>".$err;
			}else{
				$errCompile .=  trim($err);
			}
////////////////////////////////////////////////////
			// check Home email address
////////////////////////////////////////////////////
			$err = checkEmailConsistency( $IndividualId, "Individual", "Home", $row['HomeEmailAddress'], "<LI>" );
			if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
				$errCompile .=  "<LI>".$err;
			}else{
				$errCompile .=  trim($err);
			}
////////////////////////////////////////////////////
			// check Work email address
////////////////////////////////////////////////////
			$err = checkEmailConsistency( $IndividualId, "Individual", "Work", $row['WorkEmailAddress'], "<LI>" );
			if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
				$errCompile .=  "<LI>".$err;
			}else{
				$errCompile .=  trim($err);
			}
////////////////////////////////////////////////////
			// age range & Birthdate
////////////////////////////////////////////////////
			$err = checkAgeRangeBirthdateConsistency( $IndividualId, "Individual", "Work", $row['AgeRange'],$row['BirthDate'], "<LI>" );
			if(strlen(trim($errCompile))>0 and strlen(trim($err))>0) {
				$errCompile .=  "<LI>".$err;
			}else{
				$errCompile .=  trim($err);
			}

////////////////////////////////////////////////////
			//Check that there is a Family for this individual
////////////////////////////////////////////////////
			$sql_checkOrphanIndv = "Select count(*) from Family where FamilyId = ".$row['FamilyId'].";";

			$result_Fmly_Familycnt = LogQuery($sql_checkOrphanIndv,__LINE__,__FILE__ );
			$row_Fmly_Familycnt = mysql_fetch_array($result_Fmly_Familycnt );

			
			if ($row_Fmly_Familycnt [0] == 0) {
				if (!$bDebug) { print "Orphan Individual Found - $IndividualId : ".$row['FirstName']." ".$row['Surname']."<br />";}

				$errCompile="<b>Orphan individual found</b>. They are not attached to a family.";
				$errCompile.=": <a class=\"edit\" href=\"Fmly_edit.php?FamilyId=$FamilyId\" rel=\"external\"><font  ALT=\"MANUALLY EDIT THIS RECORD\">EDIT</font></a>";

				$fixLink="";
				$PHPSESSID = @$_GET['PHPSESSID'];

				$fixSQL = htmlentities(urlencode('DELETE FROM Individual WHERE IndividualId = '.$IndividualId.';'));

				$fixLink="\n</UL>\n<table border=1 cellpadding=0 cellspacing=0>\n<tr>\n<td>\n<table>";
				$fixLink.="\n<tr><td>\n";
				$fixLink.="<b><center><font class=\"UpdateLinkTitle\">CLICK LINK TO DELETE RECORD</font></center></b>";
				$fixLink.="\n</td></td>\n";
				$fixLink .= "<tr><td>\n";
				$fixLink .= '<a href="javascript:openUpdateSql(\''.$fixSQL.'\', \''.$PHPSESSID.'\')" class="UpdateLink">';
				$fixLink .= "Delete ".$row['FirstName']." ".$row['Surname']." Individual record.</a>\n";
				$fixLink .= "\n";
				$fixLink .= "</td></tr>\n</table>\n</td></tr></table>\n";

				$errCompile.=$fixLink;

				$fixLink ="";
				$fixSQL ="";



			}
			



////////////////////////////////////////////////////
			//Check that there is a Family for this individual
////////////////////////////////////////////////////
			$sql_checkOrphanIndv = "Select count(*) from Individual where Surname  = '".$row['Surname']."' AND FirstName = '".$row['FirstName']."';";

			$result_Fmly_Familycnt = LogQuery($sql_checkOrphanIndv,__LINE__,__FILE__ );
			$row_Fmly_Familycnt = mysql_fetch_array($result_Fmly_Familycnt );

			
			if ($row_Fmly_Familycnt[0] > 1 and ($prev_Surname != $row['Surname']) and ($prev_Surname != $row['FirstName'])) {
				if ($bDebug) { print "Duplicate Individuals Found - $IndividualId : ".$row['FirstName']." ".$row['Surname']." .row_Fmly_Familycnt[0] count is ".$row_Fmly_Familycnt[0]."<br />";}


				$sql_checkOrphanIndv = "Select * from Individual where Surname  = '".$row['Surname']."' AND FirstName = '".$row['FirstName']."';";
//print "sql_checkOrphanIndv  = $sql_checkOrphanIndv <br />";

				$prev_Surname = $row['Surname'];
				$prev_Surname = $row['FirstName'];
				
				$result_Fmly_Familycnt = LogQuery($sql_checkOrphanIndv,__LINE__,__FILE__ );

				$errCompile.="<UL><LI><b>Duplicate individual found</b>. Firstname and Surname match another record.</UL>";

				$fixLink="";
				$PHPSESSID = @$_GET['PHPSESSID'];

				$fixLink.="\n</UL>\n<table border=1 cellpadding=0 cellspacing=0>\n<tr>\n<td>\n<table>";
				$fixLink.="\n<tr><td>\n";
				$fixLink.="<b><center><font class=\"UpdateLinkTitle\">CLICK LINK TO DELETE RECORD</font></center></b>";
				$fixLink.="\n</td></td>\n";

				while ($row_Indv_duplicate = mysql_fetch_array($result_Fmly_Familycnt )){


					$sql_checkOrphanFIndv = "Select * from Family where FamilyId = ".$row_Indv_duplicate['FamilyId'].";";
//					print "sql_checkOrphanFIndv  = $sql_checkOrphanFIndv <br />";
					$result_Fmly_IFamilycnt = LogQuery($sql_checkOrphanFIndv,__LINE__,__FILE__ );
					$row_Fmly_IFamilycnt = mysql_fetch_array($result_Fmly_IFamilycnt );
					
					if ($bDebug) 
					{ 
		
						print "IndvID =  ".$row_Indv_duplicate['IndividualId']." : ".$row_Indv_duplicate['FirstName']." ".$row_Fmly_IFamilycnt['FamilyShortName']." (".$row_Fmly_IFamilycnt['ResidentialSuburb'].")<br />";

					
					
					}

				$errCompile.=": <a class=\"edit\" href=\"Indv_edit.php?IndividualId=".$row_Indv_duplicate['IndividualId']."\" rel=\"external\"><font  ALT=\"MANUALLY EDIT THIS RECORD\">EDIT ".$row_Indv_duplicate['IndividualId']."</font></a>";

					

				$fixSQL = htmlentities(urlencode('DELETE FROM Individual WHERE IndividualId = '.$row_Indv_duplicate['IndividualId'].';'));

				$fixLink .= "<tr><td>\n";
				$fixLink .= '<a href="javascript:openUpdateSql(\''.$fixSQL.'\', \''.$PHPSESSID.'\')" class="UpdateLink">';
				$fixLink .= "Delete IndividualId = ".$row_Indv_duplicate['IndividualId']." : ".$row_Indv_duplicate['FirstName']." ".$row_Fmly_IFamilycnt['FamilyShortName']." (".$row_Fmly_IFamilycnt['ResidentialSuburb'].")</a>\n";
				$fixLink .= "\n";
				$fixLink .= "</td></tr>\n";




					mysql_free_result($result_Fmly_IFamilycnt);

				}

//				mysql_free_result($result_Fmly_Familycnt );

				$fixLink .= "</table>\n</td></tr></table>\n";



				$errCompile.=$fixLink;

				$fixLink ="";
				$fixSQL ="";



			}









		







			// Print results
			if(strlen(trim($errCompile))>0) {
				$HtmlText .= "\n<tr><td>\n";
				$IndividualName = $row['FirstName']." ".$row['Surname'];
				$HtmlText .= "\n<a href=\"Indv_view.php?IndividualId=".$IndividualId."\" rel=\"external\" title=\"View $IndividualName's details\"> ".$IndividualName."</a>\n";
				$HtmlText .= "</td>\n\n<td><UL>\n";		
				$HtmlText .= "<LI>$errCompile</UL>\n";
				$HtmlText .= "</td></tr>\n";		
				$countFixes++;
			}

		}//end of Individual

		if($CheckLevel=="IndividualFamily") {
//			echo "<h1>Checking Indiviudual to Family</h1>";
//		echo "<LI>'Orphan Individuals\n";

//		echo "<LI>Families containing Individuals with different or no surnames\n";
		
//		echo "<LI>Familes with no 'Head Of Family'\n";
		}

	
	} // end while




	echo "\n\n<table border=1>\n";
	echo $HtmlText;
	echo "\n</table>\n\n";
}// end if
?>

<?php
//exit;
end_div_main();
?> 
<?php
include($root . 'include/footer.php');
?>